<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>缤纷课堂</title>
    <script src="http://www.hugaint.com/MAELWXSDK/jq3.3.1.js"></script>
    <script src="http://www.hugaint.com/MAELWXSDK/publicFunction.js"></script>
    <style>
        .max {
            position: fixed;
            z-index: 100;
            background-color: rgba(255, 255, 255, 0);
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
        }

        .loading-content {
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 101;
            position: absolute;
            left: 50%;
            top: 40%;
            transform: translate3d(-50%, -50%, 0);
            -webkit-transform: translate3d(-50%, -50%, 0);
            color: #fff;
            -webkit-box-align: center;
            padding: 10px 44px;
            min-height: 98px;
            background: rgba(0, 0, 0, .6);
            border-radius: 10px;
        }

        .loading-content i {
            animation: spin 6s linear infinite;
            -webkit-animation: spin .9s linear infinite;
            height: 40px;
            width: 40px;
            border: 4px solid #eee;
            border-bottom-color: transparent;
            border-radius: 100%;
            vertical-align: middle;
        }

        .loading-content p {
            margin-left: 6px;
            font-size: 20px;
        }

        .loading-mask {
            background: rgba(0, 0, 0, 0);
        }

        @keyframes spin {
            0% {
                transform: rotate(0deg);
            }
            100% {
                transform: rotate(360deg);
            }
        }

        @-webkit-keyframes spin {
            0% {
                -webkit-transform: rotate(0deg);
            }
            100% {
                -webkit-transform: rotate(360deg);
            }
        }
    </style>
</head>

<script>
    $(function () {
        let code = GetQueryString("code");
        let openid = getCookie("openid");
        if (code) {
            $.ajax({
                url: "http://jsdkapi.hugaint.com:8090/wx/getUserInfo",
                type: "post",
                dataType: "json",
                data: { code: code },
                success: function (result) {
                    if (result.status === 1) {
                        setCookie("openid", result.datas, 7);
                        $.ajax({
                            url: "http://jsdkapi.hugaint.com:8090/userInfo/findUserByOpenid",
                            type: "post",
                            dataType: "json",
                            data: { openid: result.datas },
                            success: function (result2) {
                                if (result2) {
                                    loading(false)
                                }
                                if (result2.datas) {
                                    setTimeout(() => {
                                        window.location.href = "http://www.hugaint.com/H5/activity/index.html#/myMember";
                                    }, 0)
                                } else {
                                    setTimeout(() => {
                                        window.location.href = "http://www.hugaint.com/H5/activity/index.html#/portal";
                                    }, 0)

                                }
                            }
                        })
                    }
                }
            });
        } else {
            loading(false)
            window.location.href = "http://jsdkapi.hugaint.com:8090/wx/getCode"
        }
        function loading(isShow) {
            console.log(1)
            var html = $('<div class="max">' +
                '<div class="loading-content">' +
                '<i />' +
                '<p>登陆中...</p>' +
                '</div>' +
                '</div>')
            if (isShow) {
                $('body').append(html)
            } else {
                $('.max').remove()
            }
        }
    })
</script>

<body>
</body>

</html>